package A011thread;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

class A004_实现线程方式三_实现Callable接口_实现call方法 {
    public static void main(String[] args) throws Exception {
        Callable mt = new MyThread_3();
        FutureTask<Integer> ft = new FutureTask<Integer>(mt);
        Thread t = new Thread(ft);
        t.start();
        Integer integer = ft.get();//获取到线程执行体的返回值
        System.out.println(integer);
    }
}


class MyThread_3 implements Callable<Integer> {
    int i = 0;

    @Override
    public Integer call() throws Exception {
        i++;
        return i;
    }
}